package com.kingbull.recorder;

import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
import ohos.app.Context;
import ohos.media.audio.AudioCapturerInfo;
import ohos.media.audio.AudioStreamInfo;
import om.recorder.AudioRecordConfig;
import om.recorder.OmRecorder;
import om.recorder.PullTransport;
import om.recorder.PullableSource;
import org.junit.Test;

public class ExampleOhosTest {
    private final Context context = AbilityDelegatorRegistry.getAbilityDelegator().getAppContext();


    /**
     * testPcm
     */
    @Test(expected = IllegalArgumentException.class)
    public void testPcm() {
        PullTransport.Default pullTransport = new PullTransport.Default(mic(),
                audioChunk -> {
                }
        );
        OmRecorder.pcm(pullTransport, null);
    }


    /**
     * testWav
     */
    @Test(expected = IllegalArgumentException.class)
    public void testWav() {
        PullTransport.Default pullTransport = new PullTransport.Default(mic(),
                audioChunk -> {
                }
        );

        OmRecorder.wav(pullTransport, null);
    }

    private PullableSource mic() {
        return new PullableSource.Default(
                new AudioRecordConfig.Default(
                        AudioCapturerInfo.AudioInputSource.AUDIO_INPUT_SOURCE_MIC,
                        AudioStreamInfo.EncodingFormat.ENCODING_PCM_16BIT,
                        AudioStreamInfo.ChannelMask.CHANNEL_IN_MONO, 44100
                )
        );
    }

}